﻿
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.ComponentModel.DataAnnotations;
using WalkingTec.Mvvm.Core;
using WalkingTec.Mvvm.Core.Extensions;
using Digitalmes.Model.PackageManagement;
using Digitalmes.Model;



namespace Digitalmes.ViewModel.PackageManagement.PackageParaVMs
{
    public partial class PackageParaSchemeDetailListVM : BasePagedListVM<PackagePara, PackageParaDetailSearcher>
    {
        
        protected override List<GridAction> InitGridAction()
        {
            return new List<GridAction>
            {
                this.MakeStandardAction("PackagePara", GridActionStandardTypesEnum.AddRow, "新建","", dialogWidth: 800),
                this.MakeStandardAction("PackagePara", GridActionStandardTypesEnum.RemoveRow, "删除","", dialogWidth: 800),
            };
        }
 
        protected override IEnumerable<IGridColumn<PackagePara>> InitGridHeader()
        {
            return new List<GridColumn<PackagePara>>{
                
                this.MakeGridHeader(x => x.ValueName).SetEditType(EditTypeEnum.TextBox).SetTitle(@Localizer["Page.值名称"].Value),
                this.MakeGridHeader(x => x.ValueMode).SetEditType(EditTypeEnum.ComboBox,typeof(ValueTypeEnum).ToListItems(null,true)).SetTitle(@Localizer["Page.值类型"].Value),
                this.MakeGridHeader(x => x.Value).SetEditType(EditTypeEnum.TextBox).SetTitle(@Localizer["Page.值"].Value),
                this.MakeGridHeader(x => x.Remark).SetEditType(EditTypeEnum.TextBox).SetTitle(@Localizer["_Admin.Remark"].Value),

                this.MakeGridHeaderAction(width: 200)
            };
        }

        
        public override IOrderedQueryable<PackagePara> GetSearchQuery()
        {
                
            var id = (long?)Searcher.SchemeId.ConvertValue(typeof(long?));
            if (id == null)
                return new List<PackagePara>().AsQueryable().OrderBy(x => x.ID);
            var query = DC.Set<PackagePara>()
                .Where(x => id == x.SchemeId)

                .OrderBy(x => x.ID);
            return query;
        }

    }

    public partial class PackageParaDetailSearcher : BaseSearcher
    {
        
        [Display(Name = "_Model._PackagePara._Scheme")]
        public string SchemeId { get; set; }
    }

}

